<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2022/5/9
 * Time: 10:58
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

namespace app\common\business;

use app\common\lib\Show;
use app\common\lib\Status;
use app\common\model\MallGoods;
use app\common\model\MallGoodsSku;
use app\common\model\MallOrder;
use app\common\model\MallOrderGoods;
use think\Exception;
use think\facade\Db;

class BusGoods extends Base
{
    protected $model = null;

    public function __construct()
    {
        $this->model = new MallGoods();
    }

    /**
     * @param int $num
     * @param int $shop_id
     * @return mixed
     * @throws Exception
     */
    public function getRandomGoods(int $num = 10, int $shop_id = 0)
    {
        try {

            $lists = $this->model->field('id,sku_id,title,thumb_title,price,market_price,logo')
                ->where('shop_id',$shop_id)
                ->where('is_appoint',1)
                ->order('sort desc,id desc')
                ->limit($num)
                ->select()
                ->toArray();
        }catch (\Exception $e){
            throw new Exception($e->getMessage());
        }
        return $lists;
    }
}